/**
 * Created with IntelliJ IDEA.
 * User: chenkaiyu
 * Date: 15-4-25
 * Time: 上午10:42
 * To change this template use File | Settings | File Templates.
 */

var boom = function () {
    var saveValidate = function () {
        var hgi = $("#hgi").val();
        if (hgi == "") {
            toast.error("哈氏可磨性系数HGI 不能为空！")
            return false;
        }

        return true;
    }

    var getBoom = function () {
        return{
            powerCaseId: $("#caseId").val(),
            ke: $("#ke").val()==""?0:$("#ke").val(),
            hgi: $("#hgi").val(),
            ai: $("#ai").val()==""?0:$("#ai").val()
        }
    }

    return{
        init: function () {

        },
        boomNext: function () {
            var addFlag = $("#addFlag").val();
            if (addFlag == "add") {
                toast.error("请先填写本页数据，保存成功后再进行下一页操作！");
                return;
            }
            formSub(basePath + "nature?menuId=14")
        },
        exportMzfx: function () {
            var addFlag = $("#addFlag").val();
            if (addFlag == "add") {
                toast.error("请先填写本页数据，保存成功后再进行导出操作！");
                return;
            }
            formSub(basePath + "quality/boom/exportMzfx?caseId="+$("#caseId").val())
        },
        boomSave: function () {
            if (!saveValidate())return;
            var addFlag = $("#addFlag").val();
            if (addFlag == "add" || (addFlag != "add" && confirm("确定重新计算并保存吗？"))) {
                Metronic.blockUI({
                    boxed: true,
                    message: "数据加载中..."
                });
                $.ajax({
                    url: basePath + "quality/boom/boomSave",
                    type: "post",
                    dataType: "json",
                    data: getBoom(),
                    success: function (data) {
                        Metronic.unblockUI();
                        if (data.ok) {
                            formSub(basePath + "quality/boom?menuId=11&message=success")
                        } else if (data.error) {
                            toast.error(data.returnMsg);
                            return false;
                        }
                    }
                })
            }
        }
    }
}()
